package cn.jobstart.enums;

/**
*    @author sunke
*    @Date 2023-09-06 14:17:04
*    @description 婚姻状况 0保密  1未婚 2已婚
*/
import cn.jobstart.common.NumberUtil;
import cn.jobstart.common.StringUtil;
import cn.jobstart.pubInter.EnumVO;
import org.apache.poi.ss.formula.functions.T;

import java.util.ArrayList;
import java.util.List;

public enum ResumeBasicMarriageFlagEnum {

    SECRET(0, "保密") ,
    UN_MARRIED(1, "未婚") ,
    MARRIED(2, "已婚") ;




    private Integer type;
    private String desc;

    ResumeBasicMarriageFlagEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }


    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static int getTypeByTypeStr(String type) {
        if(StringUtil.isNullOrEmpty(type)){
            return SECRET.getType().intValue();
        }
        int typeInt= NumberUtil.parseInt(type);
        for (ResumeBasicMarriageFlagEnum var : ResumeBasicMarriageFlagEnum.values()) {
            if (typeInt==var.getType().intValue()) {
                return var.getType();
            }
        }

        return SECRET.getType().intValue();


    }


    public static Integer getDescByType(String desc) {
        if (desc == null) {
            return null;
        }
        for (ResumeBasicMarriageFlagEnum var : ResumeBasicMarriageFlagEnum.values()) {
            if (var.getDesc().indexOf(desc) >= 0) {
                return var.getType().intValue();
            }
        }
        return null;
    }

    public static String getDescByType(Integer type) {
        if(type==null ){
            type=0;
        }
        for (ResumeBasicMarriageFlagEnum var : ResumeBasicMarriageFlagEnum.values()) {
            if (type==var.getType().intValue())
                return var.getDesc();
             }
        return ResumeBasicMarriageFlagEnum.values()[0].getDesc();
    }

    public static List<EnumVO> getDescs() {
        List list = new ArrayList();

        for (ResumeBasicMarriageFlagEnum var : ResumeBasicMarriageFlagEnum.values()) {
            EnumVO enumVO = new EnumVO();
            enumVO.setId(var.getType()+"");
            enumVO.setName(var.getDesc());
            list.add(enumVO);
        }


        return list;
    }

}
